<h2 class="contentTitle">添加资讯</h2>
<form action="<?php echo SITE_URL . 'index.php?a=new&m=ajaxAdd';?>" method="post" class="pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone)">
<div class="pageContent">
	<div layouth="97" class="pageFormContent nowrap" style="height: 376px; overflow: auto;">
        <dl>
            <dt>资讯名称：</dt>
            <dd>
                <input type="text" name="title" size="60" class="required textInput valid">
                <span class="inputInfo">填写资讯名称</span>
            </dd>
		</dl>
        <dl>
            <dt>资讯标签：</dt>
            <dd>
                <input type="text" name="tag" size="60" class="required textInput valid">
                <span class="inputInfo">填写资讯标签，站内搜索用</span>
            </dd>
        </dl>
        <dl>
            <dt>资讯类别：</dt>
            <dd>
                <select class="combox" name="category_id">
                    <option value="">请选择类别</option>
                    <?php
                    foreach($category_list as $k=>$v){
                        ?>
                        <option value="<?php echo $k; ?>"><?php echo $v; ?></option>
                    <?php
                    }
                    ?>
                </select>
                <span class="inputInfo">请选择类别</span>
            </dd>
		</dl>
        <dl>
            <dt>资讯来源：</dt>
            <dd>
                <select class="combox" name="source_id">
                    <option value="">请选择来源</option>
                    <?php
                    foreach($source_list as $k=>$v){
                        ?>
                        <option value="<?php echo $k; ?>"><?php echo $v; ?></option>
                    <?php
                    }
                    ?>
                </select>
                <span class="inputInfo">请选择来源</span>
            </dd>
        </dl>
        <dl>
            <dt>资讯状态：</dt>
            <dd>
                <select class="combox" name="status">
                    <option value="1">待审核</option>
                    <option value="2" selected="true">审核通过</option>
                    <option value="3">审核未通过</option>
                </select>
                <span class="inputInfo">是否显示在主站上</span>
            </dd>
        </dl>
        <dl>
            <dt style="font-weight: bold;color: red">列表推荐：</dt>
            <dd>
                <input type="radio" name="recommend" value="1" checked="true">不推荐
                <input type="radio" name="recommend" value="2">推荐
                <span class="inputInfo">是否是推荐资讯</span>
            </dd>
        </dl>
        <dl>
            <dt style="font-weight: bold;color: red">首页推荐：</dt>
            <dd>
                <input type="radio" name="recommend_index" value="1" checked="true">不推荐
                <input type="radio" name="recommend_index" value="2">推荐
                <span class="inputInfo">是否推荐到首页</span>
            </dd>
        </dl>
        <dl>
            <dt>关键词组：</dt>
            <dd>
                <textarea rows="2" cols="60" name="keywords" id="keywords" class="textInput"></textarea>
                <span class="inputInfo">页面显示时的关键词</span>
            </dd>
		</dl>
        <dl>
            <dt>资讯描述：</dt>
            <dd>
                <textarea rows="2" cols="60" name="description" id="description" class="textInput"></textarea>
                <span class="inputInfo">页面显示时的描述信息</span>
            </dd>
        </dl>
        <dl>
            <dt>资讯摘要：</dt>
            <dd>
                <textarea rows="2" cols="60" name="summary" id="summary" class="textInput"></textarea>
                <span class="inputInfo">用于列表页显示资讯用</span>
            </dd>
        </dl>
        <dl>
            <dt>资讯缩图：</dt>
            <dd>
                <input id="file_upload" type="file" name="picture"/>
                <span class="inputInfo">上传该新闻的缩略图，注意图片选择要具有吸引力</span>
                <img id= "curr_picture" src="/uploads/default/320x200.jpg" >
                <input type="hidden" name="picture" value="">

            </dd>
        </dl>
        <dl>
            <dt>资讯内容：</dt>
            <dd style="width: 700px">
                <textarea name="content" id="content" style="height: 350px; width: 700px;"></textarea>
            </dd>
        </dl>
	</div>
	<div class="formBar">
		<ul>
			<li><div class="buttonActive"><div class="buttonContent"><button type="submit">确认</button></div></div></li>
			<li><div class="button"><div class="buttonContent"><button class="close" type="button">关闭</button></div></div></li>
		</ul>
	</div>
</div>
</form>
<script type="text/javascript">

    //动态加载 Kindeditor 文本编辑器
    var  content ;
    $.getScript('<?php echo KINDEDITOR_URL; ?>kindeditor-min.js', function() {
        KindEditor.basePath = '<?php echo KINDEDITOR_URL; ?>';
        content = KindEditor.create('textarea[name="content"]', {
            themeType: 'simple',
            resizeType: 1,
            uploadJson: '<?php echo SITE_URL . 'index.php?a=upload&m=newContentUpload&type=local';?>',
            fileManagerJson: '<?php echo SITE_URL . 'index.php?a=upload&m=newContentUpload&type=http';?>',
            allowFileManager: true,
            //经测试，下面这行代码可有可无，不影响获取textarea的值
            //afterCreate: function(){this.sync();}
            //下面这行代码就是关键的所在，当失去焦点时执行 this.sync();
            afterBlur: function () { this.sync(); }
        });
    });

    //动态加载上传插件
    <?php $timestamp = time();?>
    $(function() {
        $('#file_upload').uploadify({
            'onInit': function(){
                var curr_picture = $('input[name=picture]').val();
                console.log(curr_picture);
                curr_picture = curr_picture != null && curr_picture!= '' ? curr_picture : '';
                $.cookie('curr_picture',curr_picture,{path: "/",expires:1,domain: "<?php echo CURR_DOMAIN; ?>"});
            },
            'formData'     : {
                type:'add',
                'timestamp' : '<?php echo $timestamp;?>',
                'token'     : '<?php echo md5(MD5_CODE . $timestamp);?>'
            },
            'simUploadLimit':1,
            'swf'      : '<?php echo UPLOADIFY_URL; ?>js/uploadify.swf',
            'uploader' : '<?php echo SITE_URL . 'index.php?a=new&m=newPictureUpload';?>',
            'buttonText' : '上传图片',
            fileSizeLimit:'200KB',
            fileTypeDesc:'*.jpg;*.jpeg;*.gif;*.png;',
            fileTypeExts:'*.jpg;*.jpeg;*.gif;*.png;',
            auto:true,
            multi:false,
            'onUploadError' : function(file,errorCode,errorMsg,errorString,swfuploadifyQueue){
                //alert(errorMsg);//上传文件出错是触发（每个出错文件触发一次）
                alertMsg.info(errorMsg);
            },
            'onUploadSuccess':function(file,data,response){

                var on_upload_success = $.cookie('on_upload_success');
                if($.cookie('curr_picture') && $.cookie('curr_picture') != null){
                    curr_picture = $.cookie('curr_picture');
                    $('#curr_picture').attr('src','').attr('original','');
                    $('#curr_picture').attr('src',curr_picture+'?'+Math.random()).attr('original',curr_picture);
                }else{
                    $.cookie('curr_picture',on_upload_success,{path: "/",expires:1,domain: "<?php echo CURR_DOMAIN; ?>"});
                    $('#curr_picture').attr('src',on_upload_success+'?'+Math.random()).attr('original',on_upload_success);
                    $('input[name=picture]').val(on_upload_success);
                }
                alertMsg.correct('上传图片成功！');
            },
            'onSelect': function (event, queueID, fileObj)
            {
                $("#file_upload").uploadify('settings','formData',{curr_picture: $.cookie('curr_picture')})
            }
        });
    });
</script>